package mate.business
{
	import classespinkpony.Address;
	import classespinkpony.Blog;
	
	import mx.collections.ArrayCollection;

	public class ControlPanelManager
	{
		
		public var _blogs:ArrayCollection;
		private var _blog:Blog;
		private var _address:Address;
		
		[Bindable]
		public function get address():Address
		{
			return _address;
		}

		public function set address(value:Address):void
		{
			_address = value;
			trace("invoicidman " + address.id);
		}

		[Bindable]
		public function get blogs():ArrayCollection
		{
			return _blogs;
		}

		public function set blogs(value:ArrayCollection):void
		{
			_blogs = value;
		}
		
		public function storeBlogs(blogs:Object):void
		{
			var temp: ArrayCollection = new ArrayCollection();
			
			if(blogs != null){
				for each (var blog:Blog in blogs)
				{
					var dateNumber:Number;
					
					dateNumber = Number(blog.lastedit);
					
					var currDate:Date = new Date(dateNumber*1000);
					var D:String = currDate.getDate().toString();
					var M:Number = currDate.getMonth()+ 1; //because Returns the month (0 for January, 1 for February, and so on)
					var mString = M.toString();
					var Y:String = currDate.getFullYear().toString();
					
					var theDate:String = ( D + "/" + mString + "/" + Y);
					
					blog.lastedit = theDate;
					
					temp.addItem(blog);
				}
			}
			this.blogs = temp;
		}

		[Bindable]
		public function get blog():Blog
		{
			return _blog;
		}

		public function set blog(value:Blog):void
		{
			_blog = value;
		}
		
		public function storeBlog(blog:Object):void
		{
			if(blog != null){
				for each (var b:Blog in blog)
				{
					this.blog = b;	
				}
				
			}
		}
		
		public function storeInvoiceAddress(address:Object):void
		{
			if(address != null){
				for each (var a:Address in address)
				{
					this.address = a;	
					trace("invoiceaddres " + this.address.id);
				}
			}
		}


	}
}